﻿@{
    Layout = "~/Views/Shared/_LayoutHome.cshtml";
}
<script type="text/javascript">
    function Login() {
        if ($('#usercode').val() == "") {
            alert("请输入用户名");
            return;
        }
        var loginForm = $('#LoginForm');
        loginForm.submit();
    }

    // 复选框选中事件
    $(function () {

        //点击下拉列表，将值赋给文本框
        $(".searchdrop").click(function () {
            var str = $.trim($(this).text());
            $("#conditionStr").val(str);
            $("#conditionKey").val($(this).find("input").val());
            $(".search-menu-drop").hide();

        })

        var checked = [];
        $("#submitButton").click(function () {
            $('input:checkbox:checked').each(function () {
                checked.push($(this).val());
            });
            $("#checkDatabaseID").val(checked);
        });

        //异步加载左侧信息
        var len = $('#NumLeft').val();
        for (var i = 0; i < len; i++) {
            var str = "#UpdateCatLinkNew" + i;
            $(str).click();
        }

        //异步加载右侧信息
        var len = $('#NumRight').val();
        for (var i = 0; i < len; i++) {
            var str = "#UpdateCatLinkH" + i;
            $(str).click();
        }
        //异步加载左侧友情链接
        var len = $('#LinkCount').val();
        for (var i = 0; i < len; i++) {
            var str = "#updateLink" + i;
            $(str).click();
        }
        //异步加载右侧友情链接
        var len = $('#LinkCountRight').val();
        for (var i = 0; i < len; i++) {
            var str = "#updateLinkright" + i;
            $(str).click();
        }
        //异步加载数据库列表
        $("#UpdateHomeDateBase").click();
        //页面初次加载时，默认异步加载当前分类对应的跨库数据
        $('.search-box ul li').each(function (index, item) {
            if ($(item).attr("class") == "active") {
                $(item).find("a").click();
            }
        });

    })
    //异步刷新跨库分类
    function refreshUnionDB(classID) {

        var checked = [];
        $('input:checkbox:checked').each(function () {
            checked.push($(this).val());
        });
        $("#checkDatabaseID").val(checked);
        var currentClassCode = $("#currentClassID").val();
        $("#currentClassID").val(classID);

        if (currentClassCode != undefined && currentClassCode != "") {
            addCookie("ClassCode" + currentClassCode, $("#checkDatabaseID").val(), 0);
        }

        var targetCheckDBID = getCookie("ClassCode" + classID);
        if (targetCheckDBID == undefined) {
            targetCheckDBID = "-1";
        }

        $.ajax({
            type: "GET",
            url: timestamp("@Html.Raw(Url.Action("GetDBClass", "MultiSearch"))"),
            beforeSend: function () { $("#loadingimage").show(); },
            data: { "targetClassID": classID, "preClassID": currentClassCode, "checkDBID": targetCheckDBID, "type": "Home" },
            success: function (msg) {
                $("#loadingimage").hide();
                $(".talkDiv-body").html("");
                $(".talkDiv-body").html(msg);
            },
            error: function (e) {
                $("#loadingimage").hide();
            }
        })
    }
    //点击箭头下拉
    $("body").click(function (event) {
        var $this = $(event.target);
        if ($this.attr("id") != "conditionStr" && $this.attr("class") != "dropimg" && $this.attr("class") != "search-menu-sel posr") {
            $(".search-menu-drop").hide();
        }
        else {
            $(".search-menu-drop").show();
        }
    });

</script>
<style>
    .searchdrop {
        padding-left: 15px;
    }

        .searchdrop:hover {
            background-color: #e0dfdf;
        }

    .search-menu-drop {
        width: 150px;
        height: auto;
        font-size: 12px;
        margin-top: 42px;
        border: 1px solid #3497d8;
        display: inline-block;
        overflow: auto;
    }

    /*.rightmore:link, .rightmore:visited {
        font-size: 12px;
        color: #999;
        float: right;
        margin-right: 15px;
        font-weight: normal;
    }

    .rightmore:hover {
        color: #328ae2;
    }*/
</style>
@model CNKI.TPI.Web.UI.Models.LoginModel
@using CNKI.TPI.Web.Base
@using CNKI.TPI.Web.Search.Model
@using CNKI.TPI.Web.Search.IBLL


<div class="login-container">
    <div class="login-search clearfix wrap">
        <!-- 搜索 -->
        <div class="fl search-box">
            <ul class="nav nav-tabs05 b0 clearfix">
                @if (ViewBag.UnionDBClassInfo != null && ViewBag.UnionDBClassInfo.Count > 0)
                {
                    int i = 0;
                    foreach (CNKI.TPI.Web.Search.Model.DBCLASS item in ViewBag.UnionDBClassInfo)
                    {
                        string strclass = "";
                        if (i == 0)
                        {
                            strclass = "class=active";
                        }
                        i++;
                    <li @strclass><a href="javascript:void(0);" onClick="refreshUnionDB('@item.ClassCode')" >@item.ClassName</a></li>
                    }
                }
            </ul>

            <!-- 搜索 -->
            @using (Html.BeginForm("Index", "MultiSearch", FormMethod.Post, new { @class = "search search-stg03", id = "searchForm" }))
            {
                <div class="search-area clearfix posr">
                    <div class="search-area-t clearfix">
                        <div class="search-txt">

                            <div id="j-searchMenu03" class="search-menu">

                                @{ string firstdrop = ""; //取列表第一个值作为默认值
                                   string firstdropvalue = "";
                                    <ul class="search-menu-drop" style="display: none">
                                        @if (ViewBag.SeachInfo != null)
                                        {

                                            int i = 0;
                                            foreach (CNKI.TPI.Web.Search.Model.DBUSFIELD item in ViewBag.SeachInfo)
                                            {
                                                if (i == 0)
                                                {
                                                    firstdrop = item.ShowFieldName;
                                                    firstdropvalue = item.RealFieldName;
                                                }
                                            <li class="searchdrop">
                                                <input value="@item.RealFieldName" type="hidden"/>@item.ShowFieldName</li>    
                                                i++;
                                            }
                                        }
                                    </ul>

                                    <input type="hidden" id="conditionKey" name="conditionKey" value="@firstdropvalue" />
                                    <div class="search-menu-sel posr" style="padding-left: 10px;">

                                        <input id="conditionStr" name="conditionStr" value="@firstdrop" readonly="true"
                                            style="height: 20px; padding-left: 0px; width: 70px; text-align: center; vertical-align: middle; margin-top: 5px;" />
                                        <a class='down-ic posa' href="javascript:void(0);">
                                            <img class="dropimg" src="~/images/arrow-black.gif" alt="" /></a>
                                    </div>
                                }


                            </div>
                            <input type="text" class="w470" id="searchField" name="searchField" maxlength="50" />
                        </div>
                        <div class="search-btn">
                            <input type="submit" id="submitButton" value="检 索" />
                            <a href="javascript:" class="dialog-p cBlu">跨库检索范围</a>
                        </div>
                    </div>
                    @*<div class="tr pt10">
                        <a href="javascript:" class="dialog-p cBlu">跨库检索范围</a>
                    </div>*@


                    <input type="hidden" id="checkDatabaseID" name="checkDatabaseID" value="" />
                    <input type="hidden" id="currentClassID" name="currentClassID" />
                    <!-- 弹窗 -->
                    <!--talkDiv弹出层(不带图片，宽668)-->
                    <div class="talkDiv talkW-674 hidden" style="top: 57px;">
                        <div class="talkDiv-title">
                            <a class="icon icon-close" title="关闭" href="javascript:void(0);"><i class="iconfont iconClose">&#x3437;</i></a>
                        </div>
                        <div id="loadingimage" style="display: none; margin-top: 25px; margin-left: 300px; position: absolute">
                            <img src="~/Images/loading.gif" width="50" />
                        </div>
                        <div class="talkDiv-body">
                        </div>

                        <div class="talkDiv-btn">
                            <a href="javascript:void(0);" class="btn btn-m btn-submit btn-warn-f select-all">全选</a>
                            &#12288;<a href="javascript:void(0);" class="btn btn-m btn-submit btn-prim-f cancel">取消</a>
                        </div>
                    </div>
                </div>
            }
        </div>
        <!-- 登录 -->
        <!--
        <div class="login">

            @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { id = "LoginForm", @class = "posr" }))
            {
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true)
                bool anonymousControlFlag = CNKI.TPI.Web.Base.ConfigHelper.IsAnonymousControlEnabled();
                string anonymousUsername = CNKI.TPI.Web.Base.ConfigHelper.GetAnonymousAccount();
                string currentUsername = "";
                if (CNKI.TPI.Web.Base.SessionHelper.IsUserInfoExsit())
                {
                    currentUsername = CNKI.TPI.Web.Base.SessionHelper.GetUserInfo().UserCode;
                }
                if (CNKI.TPI.Web.Base.SessionHelper.IsUserInfoExsit() && ((anonymousControlFlag && !anonymousUsername.Equals(currentUsername)) || !anonymousControlFlag))
                {
                    CNKI.TPI.Web.Search.Model.LoginUserInfo userInfo = CNKI.TPI.Web.Base.SessionHelper.GetUserInfo();
                    string username = string.IsNullOrEmpty(userInfo.UserName) ? userInfo.UserCode : userInfo.UserName;
                <div class="login-in">
                    <div class="tc pt10 pb10">
                    @*<img src="~/Images/user-icon.png" alt="用户头像" />*@
                </div>
                <h3 class="tc mb10">@username</h3>
                <div class="tc mb10">欢迎您登录</div>
                <div class="login-btn tc">
                    @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
                    {
                        @Html.AntiForgeryToken()
                        <a class="btn btn-m btn-submit btn-warn-f" href="javascript:document.getElementById('logoutForm').submit()">注销</a>
                    }
                </div>
                    </div>
                }
                else
                {
                <div class="tc login-item">用户登录</div>
                @Html.TextBoxFor(m => m.UserName, new { @class = "f-text span3", placeholder = "用户名", maxlength = "50", id = "usercode" })
                @Html.PasswordFor(m => m.Password, new { @class = "f-text span3", placeholder = "密码", maxlength = "50" })
                    
                <div class="login-btn">
                    <a class="btn btn-m block btn-warn-f" href="javascript:Login();">登录</a>
                    @*<span class="login-btn-r"><a href="">注册</a><span>|</span><a href="">忘记密码</a></span>*@
                </div>
                }
            }
        </div>
            -->
    </div>
</div>
<div class="center-box center-box-bd">
    @{var ajaxOptionsD = new AjaxOptions()
              {
                  HttpMethod = "post",
                  UpdateTargetId = "HomeDataBaseID",
                  InsertionMode = InsertionMode.Replace
              };
      string userid = "-1";
      if (CNKI.TPI.Web.Base.SessionHelper.IsUserInfoExsit())
      {
          userid = CNKI.TPI.Web.Base.SessionHelper.GetUserInfo().UserID;
      }
                        
        @Ajax.ActionLink("隐藏域3", "HomeDataBase", new { userid = userid }, ajaxOptionsD, new { id = "UpdateHomeDateBase", hidden = "hidden", style = "display:none" })}
    <div class="wrap posr" id="HomeDataBaseID">
        <img src="~/Images/loading.gif" width="50" />
    </div>
    @* <a class="posa dataBase-open gray" href="javascript:">展开<i class="iconfont">&#xe611;</i></a>*@
</div>
<div class="wrap wrap-i detail-con clearfix">
    <div class="wrap-i-l">
        <div class="xg-search xs-doc">
            @*左侧*@
            <input type="hidden" id="NumLeft" name="NumLeft" value="@ViewBag.NumLeft" />
            @if (ViewBag.LeftResult != null && ViewBag.LeftResult.Count > 0)
            {
                int j = 0;
                foreach (SYS_CMS_NEWS_NEWSCONTENTCONFIG obj in ViewBag.LeftResult)
                {
                    string stridnew = "updatedivNew" + j;
                    var ajaxOptions = new AjaxOptions()
                    {
                        HttpMethod = "post",
                        UpdateTargetId = stridnew,
                        InsertionMode = InsertionMode.Replace
                    };
                        
                @Ajax.ActionLink("隐藏域1", "SubIndexHome",
                                new { dbId = obj.DbID, type = obj.ShowType, len = obj.ArticleLength, pageSize = obj.ArticleNum, location = 0 },
                                ajaxOptions, new { id = "UpdateCatLinkNew" + j, hidden = "hidden", style = "display:none" })
                    if (obj.ShowType == (int)ShowType.PicNews || obj.ShowType == (int)ShowType.PicRecommend) //图片新闻，图片推荐的显示样式
                    {
                        
                <div class="media-container media-pic-container posr">
                    @if (obj.ShowType == (int)ShowType.PicRecommend)
                    {
                        <a target="_blank" href="~/SingleSearch?id=@obj.DbID&name=@obj.DBName&displayDBName=@Server.UrlEncode(obj.DBDisplayName)&autoLoad=1" class="more posa pos-right">更多</a>
                    }
                    else  //图片新闻栏目跳转到文献概览页
                    {
                        <a target="_blank" href="~/SingleSearch?id=@obj.DbID&name=@obj.DBName&mediaType=@((int)MediaType.Doc)&displayDBName=@Server.UrlEncode(obj.DBDisplayName)&autoLoad=1" class="more posa pos-right">更多</a>
                    }

                    <h2 class="fwb"><i class="blue-block"></i><span>@ColumnAliasHelper.SubContent(obj.ColumnName, obj.NameLength)</span></h2>
                    <div id="@stridnew">
                        <img src="~/Images/loading.gif" width="50" />
                    </div>
                </div>
                    }
                    else //其他栏目显示样式
                    {
                <div class="media-container media-container-nobd posr col-md-2">
                    @if (obj.ShowType == (int)ShowType.ArticleNews)//文章新闻栏目跳转到文献概览页
                    {
                        <a target="_blank" href="~/SingleSearch?id=@obj.DbID&name=@obj.DBName&mediaType=@((int)MediaType.Doc)&displayDBName=@Server.UrlEncode(obj.DBDisplayName)&autoLoad=1" class="more posa pos-right">更多</a>
                    }
                    else  
                    {
                        <a target="_blank" href="~/SingleSearch?id=@obj.DbID&name=@obj.DBName&displayDBName=@Server.UrlEncode(obj.DBDisplayName)&autoLoad=1" class="more posa pos-right">更多</a>
                    }

                    <h2 class="fwb"><i class="blue-block"></i><span>@ColumnAliasHelper.SubContent(obj.ColumnName, obj.NameLength)</span></h2>
                    <div id="@stridnew">
                        <img src="~/Images/loading.gif" width="50" />
                    </div>
                </div>
                    }
                    j++;
                }

            }

                 <!-- 友情链接 -->
        <input type="hidden" id="LinkCount" name="LinkCount" value="@ViewBag.LinkCount" />
        @if (ViewBag.HomeLink != null && ViewBag.HomeLink.Count > 0)
        {
            int j = 0;

            foreach (CNKI.TPI.Web.Search.Model.SYS_CMS_NEWS_JUMPTEMPLATE obj in ViewBag.HomeLink)
            {

                string linkleft = "updatedivLink" + j;
                var ajaxOptions = new AjaxOptions()
                {
                    HttpMethod = "post",
                    UpdateTargetId = linkleft,
                    InsertionMode = InsertionMode.Replace
                };
                        
            @Ajax.ActionLink("隐藏域3", "SubIndexHome",
            new { dbId = obj.DbID, type = obj.TemplateType, len = 10, pageSize = obj.ArticleLength, location = 0 },
                        ajaxOptions, new { id = "updateLink" + j, hidden = "hidden", style = "display:none" })
            <h2><i class="blue-block"></i><span>友情链接</span></h2>
            <div class="fri-link wrap" id="@linkleft">
                <img src="~/Images/loading.gif" width="50" />
            </div>
                
                j++;
            }

        }

        </div>
    </div>
    <div class="wrap-i-r">
        <!-- wrap-r-tSTART -->
        <!--右侧 -->

        <input type="hidden" id="NumRight" name="NumRight" value="@ViewBag.NumRight" />
        @if (ViewBag.RightResult != null && ViewBag.RightResult.Count > 0)
        {
            int j = 0;
            foreach (SYS_CMS_NEWS_NEWSCONTENTCONFIG obj in ViewBag.RightResult)
            {

                string stridH = "updatedivH" + j;
                var ajaxOptions = new AjaxOptions()
                {
                    HttpMethod = "post",
                    UpdateTargetId = stridH,
                    InsertionMode = InsertionMode.Replace
                };
                        
            @Ajax.ActionLink("隐藏域3", "SubIndexHome",
            new { dbId = obj.DbID, type = obj.ShowType, len = obj.ArticleLength, pageSize = obj.ArticleNum, location = 1 },
                        ajaxOptions, new { id = "UpdateCatLinkH" + j, hidden = "hidden", style = "display:none" })
                if (obj.ShowType == (int)ShowType.PicNews) //图片新闻显示样式
                {
            <div class="wrap-r-t" id="@stridH"  style="margin-top:10px">
                <img src="~/Images/loading.gif" width="50" />
            </div>
                }
                else  //其他类型显示样式
                {
            <div class="wrap-r-box">
                <h2 class="fwb">@ColumnAliasHelper.SubContent(obj.ColumnName, obj.NameLength)
                </h2>

                <div class="posr" id="@stridH">
                    <img src="~/Images/loading.gif" width="50" />
                </div>
            </div>
                }

                j++;
            }
        }

           <!-- 友情链接 -->
        <input type="hidden" id="LinkCountRight" name="LinkCountRight" value="@ViewBag.LinkCountright" />
        @if (ViewBag.HomeLinkright != null && ViewBag.HomeLinkright.Count > 0)
        {
            int j = 0;

            foreach (CNKI.TPI.Web.Search.Model.SYS_CMS_NEWS_JUMPTEMPLATE obj in ViewBag.HomeLinkright)
            {

                string linkright = "updatedivLinkr" + j;
                var ajaxOptions = new AjaxOptions()
                {
                    HttpMethod = "post",
                    UpdateTargetId = linkright,
                    InsertionMode = InsertionMode.Replace
                };
                        
            @Ajax.ActionLink("隐藏域3", "SubIndexHome",
            new { dbId = obj.DbID, type = (int)CNKI.TPI.Web.Search.IBLL.ShowType.JumpTemplate, len = 10, pageSize = obj.ArticleLength, location = 1 },
                        ajaxOptions, new { id = "updateLinkright" + j, hidden = "hidden", style = "display:none" })
                
          //  <div class="fri-link wrap" id="@linkleft">
           //     <img src="~/Images/loading.gif" width="50" />
           // </div>
              <div class="wrap-r-box">
                <h2 class="fwb">@ColumnAliasHelper.SubContent(obj.ColumnName,12)
                </h2>

                <div class="posr" id="@linkright">
                    <img src="~/Images/loading.gif" width="50" />
                </div>
            </div>
                
                j++;
            }

        }

    </div>
</div>
<script>
    //相似词检索
    $("#searchField").keyup(smartKeyup);
</script>
